<template>
  <el-dialog :visible.sync="isShow" width="80%" :title='title' append-to-body>
    <el-row>
      <el-col :span="24" class="top">
        <el-form :model="searchParams" ref="searchParams" :inline="true">
          <el-form-item label="关联订单">
            <el-input class="input" v-model="searchParams.orderId" maxlength='20' placeholder="请输入" clearable
              show-word-limit></el-input>
          </el-form-item>
          <el-form-item prop="dates" label="记录时间">
              <el-date-picker
                  v-model="searchParams.createTimeValue"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择记录日期"
                  >
                  </el-date-picker>
            </el-form-item>
          <el-form-item>
            <el-button @click="handleSearch" type="primary" icon="el-icon-search"
              style="margin-left:40px">搜索</el-button>
          </el-form-item>
        </el-form>
        <el-form>
          <el-row style="color: red">
            余额总计：{{ shopBalanceTotal }}
          </el-row>
        </el-form>
        <el-table :data="dataList" size='medium' ref="multipleTable" border>
          <el-table-column prop="id" label="id" width="50" show-overflow-tooltip></el-table-column>
          <el-table-column prop="createTime" label="记录时间" width="160">
            <template slot-scope="{row, index}">
              {{ formatTime.dateFormat('YY-MM-DD hh:mm:ss', row.createTime) }}
            </template>
          </el-table-column>
          <el-table-column prop="orderId" label="关联订单" show-overflow-tooltip width="170"></el-table-column>
          <el-table-column prop="paywayLabel" label="账户类型" show-overflow-tooltip width="100"></el-table-column>
          <el-table-column prop="sceneLabel" label="奖励类型" show-overflow-tooltip width="120"></el-table-column>
          <el-table-column prop="fromUserModel.code" label="消费用户ID" show-overflow-tooltip width="100"></el-table-column>
          <el-table-column prop="changeWay" label="变动方式">
            <template slot-scope="{row, index}">
              {{ row.changeWay=='add'?'增加':'减少' }}
            </template>
          </el-table-column>
          <el-table-column prop="money" label="金额" show-overflow-tooltip></el-table-column>
          <el-table-column prop="balanceIncomes" label="余额" show-overflow-tooltip></el-table-column>
        </el-table>
        <pagination style="background: #ffffff; height: 50px" v-show="totalSize > 0" :total="totalSize"
          :page.sync="page" :limit.sync="size" @pagination="getDataList" />
      </el-col>
    </el-row>
  </el-dialog>
</template>

<script>
import { getLearnById } from '@/api/system/learn.js'
import { findRecordIncomesList, deleteRecordIncomess } from '@/api/pay/recordIncomes.js'
export default {
  components: {
  },
  props: {
  },
  data() {
    return {
      isShow: false,
      rowId: '',
      rowData: {},
      title: '',
      page: 1,
      size: 20,
      totalSize: 0,
      dataList: [],
      searchParams: {},
      shopBalanceTotal: 0
    }
  },
  created() {
    this.searchParams.createTimeValue = this.formatTime.getCurrentDate()
  },
  methods: {
    show(val) {
      this.isShow = true
      if (val.rowId) {
        this.rowId = val.rowId
        this.title = val.title
        this.getDataList()
      }
    },
    close() {
      this.isShow = false
    },  
    handleSearch() {
      this.page = 1
      this.getDataList()
    },
    // 获取列表数据
    getDataList() {
      this.searchParams.page = this.page
      this.searchParams.size = this.size
      this.searchParams.payway = 'shop_balance'
      this.searchParams.shop = this.rowId
      findRecordIncomesList(this.searchParams).then(res => {
        if (res.data.code == 10000) {
          this.totalSize = res.data.data.total_count
          this.dataList = res.data.data.list
          this.request_post('/pay/recordIncomes/shopBalanceTotal/',this.searchParams).then(res=>{
            if(res.data.code == 10000){
              this.shopBalanceTotal = res.data.data.shopBalanceTotal
            }
          })
        }
      });
    }
  }
}
</script>

<style lang="scss" scoped></style>